package com.magnificent.graph.model;

import java.io.Serializable;

/**
 * User: Babanin
 * Date: 06.03.2010
 * Time: 10:36:40
 */
public class CellRole implements Serializable {
    public static final CellRole ACTOR = new CellRole(1);
    public static final CellRole UNDEFINED = new CellRole(0);
    public static final CellRole CORRELATION_FUNCTION = new CellRole(2);

    private int type;

    public CellRole() {
        type = UNDEFINED.getType();
    }

    public CellRole(int type) {
        this.type = type;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public static CellRole getRoleByType(int type) {
        if (type == ACTOR.type) {
            return ACTOR;
        }

        if (type == CORRELATION_FUNCTION.type) {
            return CORRELATION_FUNCTION;
        }

        return UNDEFINED;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CellRole cellRole = (CellRole) o;

        if (type != cellRole.type) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return type;
    }

    public CellRole copy(){
        return new CellRole(type);
    }
}

  /* converted to utf8 */